package com.wao.advertisement.service.mapper;

import com.wao.advertisement.domain.*;
import com.wao.advertisement.service.dto.AdvertisementDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity Advertisement and its DTO AdvertisementDTO.
 */
@Mapper(componentModel = "spring", uses = {SpaceMapper.class, })
public interface AdvertisementMapper extends EntityMapper <AdvertisementDTO, Advertisement> {

    @Mapping(source = "space.id", target = "spaceId")
    @Mapping(source = "space.name", target = "spaceName")
    AdvertisementDTO toDto(Advertisement advertisement); 

    @Mapping(source = "spaceId", target = "space")
    Advertisement toEntity(AdvertisementDTO advertisementDTO); 
    default Advertisement fromId(Long id) {
        if (id == null) {
            return null;
        }
        Advertisement advertisement = new Advertisement();
        advertisement.setId(id);
        return advertisement;
    }
}
